Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@putout/engine-parser
Advanced tools
🐊Putout engine that parses input.
npm i @putout/engine-parser
Any parser should be installed before use, but you can be sure that @babel/parse
always installed.
You can avoid using recast
and speed up parsing and printing a bit using only Babel using:
const ast = parse(source, {
printer: 'babel',
});
const code = print(ast, {
printer: 'babel',
});
You can use brand new @putout/printer
which formats code according to eslint-plugin-putout
rules but without using ESLint.
const ast = parse(source, {
printer: 'putout',
});
const code = print(ast, {
printer: 'putout',
});
When you need to pass options, use:
const code = print(ast, {
printer: ['putout', {
format: {
indent: ' ',
},
}],
});
Print code from ast
You can add default options
for custom parser
you use.
parse
without memoization
.
create node using memoization
.
create node without memoization
.
You have two ways to benefit from source map generation:
Recast
print;Babel
generator;const source = `const hello = 'world';`;
const ast = parse(source, {
sourceFileName: 'hello.js',
});
print(ast, {
sourceMapName: 'hello.map',
});
// returns
`const hello = 'world';
{"version":3,"sources":["hello.js"],"names":[],"mappings":"AAAA...","file":"hello.map","sourcesContent":["const hello = 'world';"]}`;
To generate sourcemap using babel generator, you should use babel parser before.
This is low level transformation, because Babel
doesn't preserve any formatting.
const {generate} = require('@putout/engine-parser');
const babel = require('@putout/engine-parser/babel');
const ast = babel.parse(source, {
sourceFilename: 'hello.js',
});
generate(ast, {
sourceMaps: true,
}, {
'hello.js': source,
});
// returns
({
code,
map,
});
const {parse} = require('@putout/engine-parser');
const parser = 'acorn';
const code = parse('var t = "hello"', {
parser,
});
MIT
FAQs
🐊Putout parser
The npm package @putout/engine-parser receives a total of 12,997 weekly downloads. As such, @putout/engine-parser popularity was classified as popular.
We found that @putout/engine-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.